<!-- 聊天原代码 -->
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8"> 
		<title></title>
		<link rel="stylesheet" type="text/css" href="/statics/sp/css/reset.css"/>
		<link rel="stylesheet" href="/statics/sp/css/chat.css">
		<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
		<script src="https://cdn.jsdelivr.net/npm/vue@2.6.11"></script>
		<script src="https://unpkg.com/element-ui/lib/index.js"></script>
		<script type="text/javascript" src="/statics/sp/sdk/webimSDK3.1.2.js"></script>
		<script type="text/javascript" src="/statics/sp/sdk/EMedia_x1v1.js"></script>
		<script type="text/javascript" src="/statics/sp/js/jquery-1.9.1.min.js"></script>
		<script type="text/javascript" src="/statics/sp/js/WebIMConfig.js"></script>
		<script type="text/javascript" src="/statics/sp/js/localstorage.js"></script>
		<script type="text/javascript" src="/statics/sp/utils/getMsgData.js"></script>
		<script type="text/javascript" src="/statics/sp/utils/msgtype.js"></script>
		<script type="text/javascript" src="/statics/sp/utils/dialog.js"></script>
		<script type="text/javascript" src="/statics/sp/utils/login.js"></script>
		<script type="text/javascript" src="/statics/sp/js/webconn.js"></script>
		<script type="text/javascript" src="/statics/sp/sdk/vconsole.min.js"></script>
	</head>
	<body>
		<div class="chatBigBox" id="chatBigBox" @click="close">
			<p>{{name}}</p>
			<div class="chatInnerBox">
				<div class="friendsListBox">
					<div class="friendsList_LeftBox">
						<img class="selavatar" src="/statics/sp/img/avatar.jpg" >
						<el-badge :is-dot="allisdot" class="itemdot">
							<div :class="[{lefticonbox1_ac:current_lefticon == 0},'lefticonbox','lefticonbox1']" @click="choselefticon(0)"></div>
						</el-badge>
						<div :class="[{lefticonbox2_ac:current_lefticon == 1},'lefticonbox','lefticonbox2']" @click="choselefticon(1)"></div>
						<div :class="[{lefticonbox3_ac:current_lefticon == 2},'lefticonbox','lefticonbox3']" @click="choselefticon(2)"></div>
					</div>
					<div class="friendsList_RightBox">
						<div class="friendBox">
							<div class="chattitbox">
								<div class="searchbox">
									<el-input
									  class="seabinp"
									  placeholder="请输入内容"
									  prefix-icon="el-icon-search"
									  v-model="searfr"
									  @input="changeinp"
									  clearable>
									</el-input>
									<div @mouseenter="showaddbox = true" @mouseleave="showaddbox = false">
										<img class="addic" src="/statics/sp/img/addic.png">
										<div v-if="showaddbox" class="addBox">
											<p @click="showaddfri = true">添加好友</p>
											<p @click="showaddgroup = true">创建群组</p>
											<p @click="showjoingroup = true">加入群组</p>
										</div>
									</div>
									
								</div>
							</div>
						</div> 
						<div class="scrollleftbox">
							<div v-if="current_lefticon == 0" :class="[{chosefrienbox:current == item.name},'eachFrienBox']" v-for="(item,index) in friendshowList" :key="index" @click="choseFriendChat(index)">
								<el-badge :value="item.noreadnum" :hidden="item.ishidden" class="itemdot">
									<img class="listavatar" src="/statics/sp/img/avatar.jpg" >
								</el-badge>
								<div class="friendBox friendreaBox">
									<p class="friendname">{{item.name}}</p>
									<p class="friendchat">{{item.lastmsg}}</p>
								</div>
								<div class="time">{{item.time}}</div>
							</div>
							<div v-if="current_lefticon == 1" :class="[{chosefrienbox:current_addressbook == index},'eachFrienBox']" v-for="(item,index) in friendList" :key="index" @click="choseAddressbook(index)">
								<img class="listavatar" src="/statics/sp/img/avatar.jpg" >
								<div class="friendBox friendreaBox">
									<p class="friendname tongxunbox">{{item.name}}</p>
									<!-- <p class="friendchat">{{item.lastmsg}}</p> -->
								</div>
								<!-- <div class="time">{{item.time}}</div> -->
							</div>
							<div v-if="current_lefticon == 2" :class="[{chosefrienbox:current_group == index},'eachFrienBox']" v-for="(item,index) in groupList" :key="index" @click="choseGroupChat(index)">
								<el-badge :value="item.noreadnum" :hidden="item.ishidden" class="itemdot">
									<img class="listavatar" src="/statics/sp/img/avatar.jpg" >
								</el-badge>
								<div class="friendBox friendreaBox">
									<p class="friendname tongxunbox">{{item.name}}</p>
									<!-- <p class="friendchat">{{item.lastmsg}}</p> -->
								</div>
								<!-- <div class="time">{{item.time}}</div> -->
							</div>
						</div>			
						<div class="left_bottombox">
							<el-badge :is-dot="isdot" class="itemdot">
								<div class="newfri" @click="showasklist">
								</div>
							</el-badge>
						</div>
					</div>
				</div>
				<div v-if="showchat" class="chatListBox">
					<div class="friendnametit">
						<p>{{yourname}} {{groupid}}</p>
						<!-- <p>哦哦哦</p> -->
						<div class="oicon1" @click="showchatmess"></div>
					</div>
					<div class="msgListBox">
						<div class="message" v-for="(item,index) in txtlist" :key="item">
							<div v-if="item.self == 'self' || item.self == 'main'" :class="item.self == 'self' ? 'self' : 'main'">
								<div class="user">
									<span v-if="item.self == 'main'" class="user-text">{{item.from}}</span>
									<span v-if="item.self == 'self'" class="user-text">{{name}}</span>
								</div>
								<img class="avatar" src="/statics/sp/img/theme@2x.png"/>
								<div class="msg">
									<img v-if="item.self == 'main'" src="/statics/sp/img/popleftarrow@2x.png" class="msg_popleftarrow"/>
									<img v-if="item.self == 'self'" src="/statics/sp/img/poprightarrow@2x.png" class="msg_poprightarrow"/>
									<span v-if="item.type == 'txt' || item.type == 'emoji'" class="msginnerbox" v-for="(valitem,valindex) in item.value" :key="valindex">
									<span v-if="valitem.type == 'txt'">{{valitem.data}}</span>
									<img v-if="valitem.type == 'emoji'" class="emojiitem2" :src="emojilist.path+valitem.data" ></img>
									</span>
									<!-- <img style="width: 250px;" v-if="item.type == 'img'" class="imgitem" :src="item.value" mode="aspectFill" @click="predivimg(item.id)"></img> -->
									<el-image 
										v-if="item.type == 'img'"
										class="imgitem"
									    style="width: 250px;"
									    :src="item.value" 
									    :preview-src-list="item.valuearr">
									  </el-image>
									<audio-msg
										v-if="item.type == 'audio'"
										:msg="item"></audio-msg>
								</div>
								</div>
								<div v-if="item.self == 'other' && !item.isvideo" class="outlinemesbox">
									<p>{{item.value}}1</p>
								</div>
								
								<div v-if="item.self == 'websocmes' && item.websocmes" class="outlinemesbox">
									<p>{{item.value[0].data}}2</p>
								</div>
								
								<div v-if="item.self == 'other' && item.isvideo && videochatting" class="videochatbox" @click="joinvideo">
									<p>{{item.value[0].data}}3</p>
								</div>
								
								<div v-if="item.self == 'other' && item.issharescream" class="videochatbox" @click="joinsharevideo">
									<p>{{item.value[0].data}}4</p>
								</div>
							</div>
							
					</div>
					<div class="chatInpBox">
						<div class="menubox">
							<div class="eachmenu eachmenu1" @click.stop="openemoji"></div>
							<div class="eachmenu eachmenu2">
								<!-- <input type="file" id="fileinp" value=""  @change="sendfile" accept="application/x-zip-compressed,application/x-rar-compressed"/> -->
							</div>
							<div class="eachmenu eachmenu5">
								<input type="file" id="fileinp" value=""  @change="sendimg" accept="image/*"/>
							</div>
							<div class="eachmenu eachmenu3"></div>
							<div class="eachmenu eachmenu4" @click="creatMeeting"></div>
							<div class="eachmenu eachmenu6" @click="shareScream"></div>
							<div class="sendbtn" @click="sendMsg">发送</div>
							<div class="emojibox" v-if="showemoji">
								<div class="eachemoji"
								class="emoitem" 
								v-for="(emojitem,index) in emojilist.map"
								:key="index"
								@click="tapemoji(emojitem)"
							>
								<img :src="emojilist.path+emojitem" >
							</div>
							</div>
						</div>
						<div class="textBox">
							<textarea @keyup.enter="sendMsg" v-model="value"></textarea>
						</div>
					</div>
				</div>
				
					<div v-if="showfriendask" class="friendAskBox">
							<div class="friendnametit">好友请求</div>
							<div class="friendAskListBox">
								<div class="askInnerbox" v-for="(item,index) in friendasklist" :key="index">
									<img class="friendAskimg" src="/statics/sp/img/avatar.jpg" >
									<div class="friendAskMesbox">
										<p class="friendAskname">{{item.from}}</p>
										<p class="friendAskmes">{{item.status}}</p>
									</div>
									<div class="friendAskBtn">
										<el-button v-if="!item.isadd" type="primary" size="small" plain @click="acceptask(item)">同意</el-button>
										<el-button v-if="!item.isadd" type="danger" size="small" plain @click="rejectask(item)">拒绝</el-button>
										<p v-if="item.isadd">已添加</p>
									</div>
								</div>
							</div>
					</div>			
					<div v-if="showfriendDetail" class="friendAskBox friendDetailBox">
						<div class="friendnametit">好友详情</div>
						<div class="friendAskListBox">
							<div class="askInnerbox">
								<!-- <div class="friendDetailMes"> -->
									<img class="friendAskimg" src="/statics/sp/img/avatar.jpg" >
									<p class="friendAskname">{{friendDetailData.name}}</p>
								<!-- </div> -->
								<div class="friendAskBtn">
									<el-button type="primary" size="small" plain @click="chosepepsend">发消息</el-button>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div v-if="showaddfri" class="popbox">
					<div class="addfriendBox">
						<p class="addfrbtit">添加好友</p>
						<div class="addfriendinbox">
							<el-input
							  class="seabinp"
							  placeholder="请输入好友ID"
							  v-model="friendId"
							  clearable>
							</el-input>
							<el-input
							  type="textarea"
							  :rows="2"
							  placeholder="请输入申请消息"
							  v-model="friendasksend">
							</el-input>
							<el-button type="primary" plain @click="addfrifunc">发送申请</el-button>
						</div>
						<img class="closeaddfr" src="/statics/sp/img/closeb.png" @click="showaddfri = false">
					</div>
				</div>
				<div v-if="showaddgroup" class="popbox">
					<div class="addfriendBox addgroupBox">
						<p class="addfrbtit">创建群组</p>
						<div class="addfriendinbox">
							<el-input
							  class="seabinp"
							  placeholder="请输入群组名称"
							  v-model="groupname"
							  clearable>
							</el-input>
							<div class="friendAskListBox groupAskListBox">
								<div class="groupinnerbox" v-for="(item,index) in friendList" :key="index" @click="chosefrtogrou(index)">
									<img class="friendAskimg" src="/statics/sp/img/avatar.jpg" >
									<p class="friendAskname groupAskname">{{item.name}}</p>
									<div class="friendAskBtn">
										<img v-if="item.chose" class="chosegroupicon" src="/statics/sp/img/choseg.png">
										<img v-else class="chosegroupicon" src="/statics/sp/img/nochoseg.png">
									</div>
								</div>
							</div>
							<el-button type="primary" plain @click="createGroup">创建</el-button>
						</div>
						<img class="closeaddfr" src="/statics/sp/img/closeb.png" @click="showaddgroup = false">
					</div>
				</div>
				<div v-if="showjoingroup" class="popbox">
					<div class="addfriendBox addgroupBox joingroupBox">
						<p class="addfrbtit">加入群组</p>
						<div class="addfriendinbox">
							<el-input
							  class="seabinp"
							  placeholder="请输入群组号"
							  v-model="groupcode"
							  clearable>
							</el-input>
							<el-button type="primary" plain @click="joinGroup">申请加入</el-button>
						</div>
						<img class="closeaddfr" src="/statics/sp/img/closeb.png" @click="showjoingroup = false">
					</div>
				</div>
				<div v-if="showsetgroupaddm" class="popbox">
					<div class="addfriendBox addgroupBox">
						<p class="addfrbtit">添加群成员</p>
						<div class="addfriendinbox">
							<el-input
							  class="seabinp"
							  placeholder="搜索需要加入群组的好友"
							  v-model="membernameadd"
							  @input="searchsetmemberadd"
							  clearable>
							</el-input>
							<div class="friendAskListBox groupAskListBox">
								<div class="groupinnerbox" v-for="(item,index) in setFriendList" :key="index" @click="chosesetmemberadd(index)">
									<img class="friendAskimg" src="/statics/sp/img/avatar.jpg" >
									<p class="friendAskname groupAskname">{{item.name}}</p>
									<div class="friendAskBtn">
										<img v-if="item.chose" class="chosegroupicon" src="/statics/sp/img/choseg.png">
										<img v-else class="chosegroupicon" src="/statics/sp/img/nochoseg.png">
									</div>
								</div>
							</div>
							<el-button type="primary" plain @click="setGroupBtnAdd">添加群成员</el-button>
						</div>
						<img class="closeaddfr" src="/statics/sp/img/closeb.png" @click="showsetgroupaddm = false">
					</div>
				</div>
				<div v-if="showsetgroup" class="popbox">
					<div class="addfriendBox addgroupBox">
						<p class="addfrbtit">删除群成员</p>
						<div class="addfriendinbox">
							<el-input
							  class="seabinp"
							  placeholder="搜索群成员"
							  v-model="membername"
							  @input="searchsetmember"
							  clearable>
							</el-input>
							<div class="friendAskListBox groupAskListBox">
								<div class="groupinnerbox"  v-for="(item,index) in showsetmemberList" :key="index" @click="chosesetmember(index)">
									<img class="friendAskimg" src="/statics/sp/img/avatar.jpg" >
									<p class="friendAskname groupAskname">{{item.memberid}}</p>
									<div class="friendAskBtn">
										<img v-if="item.chose" class="chosegroupicon" src="/statics/sp/img/choseg.png">
										<img v-else class="chosegroupicon" src="/statics/sp/img/nochoseg.png">
									</div>
								</div>
							</div>
							<el-button type="primary" plain @click="setGroupBtn">删除群成员</el-button>
						</div>
						<img class="closeaddfr" src="/statics/sp/img/closeb.png" @click="showsetgroup = false">
					</div>
				</div>
				<div v-if="showrightside && type=='groupchat'" class="rightSidebox">
					<img class="closei" src="/statics/sp/img/closei.png" @click="showrightside = false">
					<div class="friendBox">
						<div class="chattitbox">
							<div class="searchbox">
								<el-input
								  class="seabinp seabinp2"
								  placeholder="搜索群成员"
								  prefix-icon="el-icon-search"
								  v-model="searrightmes"
								  @input="changeinprightmes"
								  clearable>
								</el-input>
							</div>
						</div>
					</div>
					<div class="rightSide_BottBox">
						<div class="groupMemberbox">
							<div class="memberbox" v-if="isgroupowner" @click="setgroup(0)">
								<img class="memberavatar" src="/statics/sp/img/addm.png">
								<p>添加</p>
							</div>
							<div class="memberbox" v-if="isgroupowner" @click="setgroup(1)">
								<img class="memberavatar" src="/statics/sp/img/reducem.png">
								<p>删除</p>
							</div>
							<div class="memberbox" v-for="(item,index) in showchatmemberList" :key="index"> 
								<img class="memberavatar" src="/statics/sp/img/avatar.jpg">
								<p>{{item.memberid}}</p>
							</div>
							<div class="clear"></div>
							<el-button v-if="!isgroupowner" type="danger" plain @click="outGroupPop = true">删除并退出</el-button>
							<el-button v-if="isgroupowner" type="danger" plain @click="killGroupPop = true">解散该群</el-button>
						</div>
					</div>
				</div>	
				<div v-if="showrightside && type=='chat'" class="rightSidebox rightSidebox_chat">
					<img class="closei" src="/statics/sp/img/closei.png" @click="showrightside = false">
					<div class="rightSide_BottBox">
						<div class="groupMemberbox">
							<div class="memberbox"> 
								<img class="memberavatar" src="/statics/sp/img/avatar.jpg">
								<p>{{yourname}}</p>
							</div>
							<div class="clear"></div>
							<el-button type="danger" plain @click="delfriend">删除好友</el-button>
						</div>
					</div>
				</div>	
				<!-- 群员退出群的弹窗 -->
				<el-dialog
				  title="提示"
				  :visible.sync="outGroupPop"
				  width="30%"
					>
				  <span>确定要退出该群吗？</span>
				  <span slot="footer" class="dialog-footer">
				    <el-button @click="outGroupPop = false">取 消</el-button>
				    <el-button type="primary" @click="outGroup">确 定</el-button>
				  </span>
				</el-dialog>
				<!-- 群员退出群的弹窗 -->
				<!-- 群管理员解散群的弹窗 -->
				<el-dialog
				  title="提示"
				  :visible.sync="killGroupPop"
				  width="30%"
					>
				  <span>确定要解散该群吗？</span>
				  <span slot="footer" class="dialog-footer">
				    <el-button @click="killGroupPop = false">取 消</el-button>
				    <el-button type="primary" @click="killoutGroup">确 定</el-button>
				  </span>
				</el-dialog>
				<!-- 群管理员解散群的弹窗 -->
				<div v-if="showvideocall" id="videobox" class="videoboxclass">
					<div class="videobtnbox">
						<el-button type="danger" size="small" plain @click="outvideo">退出</el-button>
						<el-button type="danger" size="small" plain @click="pausevideo">{{pausetxt}}</el-button>
					</div>
				</div>
		</div>
	</body>
</html>
<script type="text/javascript">
	WebIM.message = WebIM.default.message;
	// 初始化vConsole
	// window.vConsole = new window.VConsole({
	//   defaultPlugins: ['system', 'network', 'element', 'storage'], // 可以在此设定要默认加载的面板
	//   maxLogNumber: 1000,
	//   // disableLogScrolling: true,
	//   onReady: function() {
	//     console.log('vConsole is ready.');
	//   },
	//   onClearLog: function() {
	//     console.log('on clearLog');
	//   }
	// });
	var webvue = new Vue({
		el: '#chatBigBox',
		data() {
			return {
				friendList:[],//所有好友消息列表
				friendshowList:[],//展示的好友消息列表
				txtlist:getDialog(),//对话数组
				emojilist:getemoji(),//表情数据
				showemoji:false,//显示表情框
				value:'',
				sendID:'',//接收方id
				name:'',//发送方id
				searfr:'',//搜索消息列表的data
				friendId:'',//添加好友的id
				showaddfri:false,//显示添加好友的输入框
				showaddgroup:false,//显示创建群的窗口
				showjoingroup:false,//显示加入群的窗口
				groupcode:'',//加入群时填写的群号
				isdot:false,//是否有好友请求
				showchat:false,//显示对话框
				friendasksend:'',//添加好友时的内容
				friendasklist:getFriendAskList(),//申请好友信息列表
				current:-1,//当前对话索引
				current_lefticon:0,//左边栏选项索引
				showaddbox:false,//显示添加好友、创建群组选择框
				groupList:[],//群组列表
				current_group:-1,//群组当前对话索引
				isgroup:false,//当前是否为群组消息
				groupid:'',//群组id
				yourname:'',//显示对话框名字
				groupname:'',//创建群组的名字
				begrouparr:[],//将要拉入群的好友
				showrightside:false,//显示右边栏
				current_addressbook:-1,//通讯录索引
				showfriendask:false,//显示好友请求列表
				showfriendDetail:false,//显示好友详情
				friendDetailData:{},//显示好友详的信息
				type:'',//聊天类型
				allisdot:false,//消息图标小红点
				chatmemberList:[],//打开聊天详情的所有成员列表
				showchatmemberList:[],//打开聊天详情的显示成员列表
				setmemberList:[],//设置群组添加删除的成员列表(所有)
				showsetmemberList:[],//设置群组添加删除的成员列表(显示)
				groupowner:'',//群组管理员id
				isgroupowner:false,//是否为群组管理员
				showsetgroup:false,//显示设置群成员框（删除）
				showsetgroupaddm:false,//显示设置群成员框（添加）
				setgroupmes:'',//"删除群成员"，“添加群成员”
				membername:'',//删除时搜索群成员的名字
				membernameadd:'',//添加时搜索群成员的名字
				groupsetstatus:'',//0 添加，1 删除
				setmemberarr:[],//需要设置的群成员数组,
				setFriendList:[],//添加群成员的好友列表
				searrightmes:'',//群详情搜索绑定词
				outGroupPop:false,//退群的pop
				killGroupPop:false,//解散群的pop
				ifsomebodyout:false,//有人退出群时显示“xxx退群了”
				outlist:[],//退群的人列表
				confrId:'',//视频会议id
				password:'',//视频会议秘密
				showvideocall:false,//视频会议显示
				videochatting:false,//是否正在视频会议中
				pausetxt:'暂停'
			}
		},
		mounted(){
			var that = this;
			isfirst = false;
			relogin() 
			this.name = getStorage('myid');
			console.log(this.name)
			window.onbeforeunload = function (e) {
				console.log('离开了')
				that.outvideo()
			};
		},
		methods:{
			openemoji(){
				this.showemoji = true;
			},
			close(){
				this.showemoji = false;
			},
			sendMsgkey(e){
				console.log(e.target.value)
				if(e.target.value){
					console.log(e.target.value)
				}
				console.log('aa')
			},
			sendMsg(){
				var that = this;
				if(this.value != ''){
					this.sendmsgfunc(this.value);
					this.value = '';
				}	
			},
			sendmsgfunc(value,videomes){
				var that = this;
				if(this.isgroup){
					sendID = this.groupid
				}else{
					sendID = this.sendID
				} 
				if(videomes == 'isvideo'){
					//发起视频会议
					var ext = {
						other:'videocall',
						confrId:that.confrId,
						password:that.password
					}
				}else if(videomes == 'websocmes'){
					//退出视频会议
					var ext = {
						other:'websocmes',
						confrId:that.confrId,
						password:that.password
					}
				}else if(videomes == 'issharescream'){
					//发起共享桌面
					var ext = {
						other:'issharescream',
						confrId:that.confrId,
						password:that.password
					}
				}else if(videomes == 'closevideochatting'){
					var ext = {
						other:'closevideochatting',
					}
				}else{
					var ext = {
						other:''
					}
				}
				console.log('sendID:'+that.sendID)
				var id = conn.getUniqueId();                 // 生成本地消息id
				var msg = new WebIM.message('txt', id);      // 创建文本消息
				var option = {
					msg: value,                  // 消息内容
					from:that.name,
					to: that.sendID,                          // 接收消息对象（用户id）
					roomType: false,
					ext: ext,                                  //扩展消息
					success: function (id, serverMsgId) {
						console.log('send private text Success');  
					},                                       // 对成功的相关定义，sdk会将消息id登记到日志进行备份处理
					fail: function(e){
						console.log("Send private text error");  
					}                                        // 对失败的相关定义，sdk会将消息id登记到日志进行备份处理
				};
				msg.set(option);
				console.log(this.type)
				if(this.type == 'groupchat'){
					msg.setGroup('groupchat');
				}
				if(videomes == 'isvideo'){
					this.videochatting = true;
					var msgData = {
						self:'other',
						type:msgtype().TEXT,
						value:value,
						from:msg.body.from,
						to:msg.body.to,
						isvideo:true,
					}
				}else if(videomes == 'websocmes'){
					var msgData = {
						self:'websocmes',
						type:msgtype().TEXT,
						value:value,
						from:msg.body.from,
						to:msg.body.to,
						websocmes:true
					}
				}else if(videomes == 'issharescream'){
					var msgData = {
						self:'other',
						type:msgtype().TEXT,
						value:value,
						from:msg.body.from,
						to:msg.body.to,
						issharescream:true
					}
				}else if(videomes == 'closevideochatting'){
					var msgData = {
						self:'closevideochatting',
						type:msgtype().TEXT,
						value:value,
						from:msg.body.from,
						to:msg.body.to,
						issharescream:true
					}
				}else{
					var msgData = {
						self:'self',
						type:msgtype().TEXT,
						value:value,
						from:msg.body.from,
						to:msg.body.to
					}
				}
				if(videomes != 'closevideochatting'){
					pushDialog(getMsgData(msgData,msgtype().TEXT))
				}
				// this.value = '';
				console.log(getDialog())
				console.log(msg)
				conn.send(msg.body);
				this.scrolllistbox()
			},
			tapemoji(emoji){
				let emojival;
				for(var key in this.emojilist.map){
					if(this.emojilist.map[key] == emoji){
						emojival = key
					}
					// console.log(key); 
				}
				if(this.value){
					this.value = this.value+emojival
				}else{
					this.value = emojival
				}
			},
			sendfile(){},
			sendimg(){
				console.log('发图了')
				var that = this;
				var id = conn.getUniqueId();                   // 生成本地消息id
				var msg = new WebIM.default.message('img', id);        // 创建图片消息
				var input = document.getElementById('fileinp');  // 选择图片的input
				var file = WebIM.default.utils.getFileUrl(input);      // 将图片转化为二进制文件
				var sendID;
				if(this.isgroup){
					sendID = this.groupid
				}else{
					sendID = this.sendID
				}
				console.log('sendID:'+sendID)
				var allowType = {
				    'jpg': true,
				    'gif': true,
				    'png': true,
				    'bmp': true
				};
				if (file.filetype.toLowerCase() in allowType) {
				    var option = {
				        apiUrl: WebIM.config.apiURL,
				        file: file,
				        from:that.name,
				        to: that.sendID,
				        ext: {
				            
				        },           // 接收消息对象
				        roomType: false,
				        chatType: 'singleChat',
				        onFileUploadError: function () {      // 消息上传失败
				            console.log('onFileUploadError');
				        },
				        onFileUploadComplete: function () {   // 消息上传成功
				            console.log('onFileUploadComplete');
				        },
				        success: function () {                // 消息发送成功
				            console.log('Success');
				        },
				        flashUpload: WebIM.flashUpload
				    };
				    msg.set(option);
					if(this.type == 'groupchat'){
						msg.setGroup('groupchat');
					}
				    conn.send(msg.body);
					let msgData = {
						self:'self',
						type:msgtype().IMAGE,
						value:msg.value.url,
						valuearr:[msg.value.url],
						from:msg.body.from,
						to:msg.body.to
					}
					pushDialog(msgData)
					console.log(getDialog())
					console.log(msg)
					this.scrolllistbox()
				}
			},
			scrolllistbox(){
				console.log('滚动')
				$(".msgListBox").animate({scrollTop:$(".msgListBox").prop("scrollHeight")})
			},
			changeinp(){
				if(this.searfr){
					this.friendshowList = [];
					this.friendList.forEach((item,index)=>{
						if(item.name.indexOf(this.searfr)>-1){
							this.friendshowList.push(item)
						}
					})
				}else{
					this.friendshowList = this.friendList
				}
			},
			changeinprightmes(){
				if(this.searrightmes){
					this.showchatmemberList = [];
					this.chatmemberList.forEach((item,index)=>{
						if(item.memberid.indexOf(this.searrightmes)>-1){
							this.showchatmemberList.push(item)
						}
					})
				}else{
					this.showchatmemberList = this.chatmemberList
				}
			},
			addfrifunc(){
				var that = this;
				if(this.friendId){
					WebIM.conn.subscribe({
					    to: that.friendId,
					    message: that.friendasksend   
					});
					this.showaddfri = false;
					this.friendId = '';
				}else{
					
				}
			},
			showasklist(){
				this.resetmiddle()
				this.showchat = false;
				this.showfriendask = true;
				this.isdot = false;
				this.current_lefticon = -1;
			},
			acceptask(item){
				var that = this;
				if (item.type === 'subscribe') {			  
				    /*同意添加好友操作的实现方法*/
				    conn.subscribed({
				      to: item.from,
				      message : '[resp:true]',
					  success:function(){
						  that.getFriends()
					  }
				    });
				  }else if(item.type === 'joinGroupNotifications'){
					  /*同意对方入群申请*/
					  var options = {
						  applicant: item.from,                          // 申请加群的用户名
						  groupId: item.groupid,                              // 群组ID
						  success: function(resp){
							  console.log(resp);
							  that.getGroups()
							  that.$message({
								message: '操作成功',
								type: 'success'
							  });
							  item.isadd = true;
						  },
						  error: function(e){}
					  };
					  conn.agreeJoinGroup(options);
				  }
			},
			rejectask(item){
				if (item.type === 'subscribe') {			  
				    /*拒绝添加好友的方法处理*/
					conn.unsubscribed({
					  to: item.from,
					  message : 'rejectAddFriend'
					});
				  }
			},
			choseFriendChat(index){
				this.resetmiddle();
				this.current = this.friendshowList[index].name;
				this.sendID = this.friendshowList[index].sendID;
				this.yourname = this.friendshowList[index].name;
				this.type = this.friendshowList[index].type;
				this.friendshowList[index].ishidden = true;
				this.friendshowList[index].noreadnum = 0;
				diaglog = [];
				this.txtlist = getDialog();
				this.showchat = true;			
				this.ifallmsgclear()
				console.log(this.sendID)
			},
			choseGroupChat(index){
				this.resetmiddle();
				this.current_group = index;
				this.yourname = this.groupList[this.current_group].name;
				diaglog = [];
				this.txtlist = getDialog();
				// this.showchat = true;
				this.groupid = this.groupList[this.current_group].groupid;
				console.log(this.sendID)
				this.friendDetailData = {
					sendID:this.groupid,
					name:this.groupList[this.current_group].name,
					type:'groupchat'
				}
				this.showfriendDetail = true;
			},
			choselefticon(index){
				this.resetleft()
				this.current_lefticon = index;
				this.resetmiddle()
				if(index == 0){
					this.isgroup = false;
				}else if(index == 2){
					this.isgroup = true;
				}
			},
			createGroup(){
				var groupname;
				var that = this;
				if(this.groupname){
					groupname = this.groupname;
				}else{
					groupname = this.begrouparr.toString();
				}
				this.friendList.forEach((item)=>{
					if(item.chose){
						this.begrouparr.push(item.name)
					}
				})
				if(this.begrouparr.length<=0){
					this.$message.error('请选择好友');
					return
				}
				var options = {
					data: {
						groupname: groupname,                    // 群组名
						desc: groupname,                          // 群组描述
						members: this.begrouparr,            // 用户名组成的数组
						public: true,                         // pub等于true时，创建为公开群
						approval: true,                  // approval为true，加群需审批，为false时加群无需审批
						allowinvites: false           // true：允许群成员邀请人加入此群，false：只有群主才可以往群里加人   
					},
					success: function (respData) {
						that.$message({
						  message: '创建成功',
						  type: 'success'
						});
						that.showaddgroup = false;
						that.getGroups()
					},
					error: function (res) {
						console.log('error')
						console.log(res)
					}
				};
				conn.createGroupNew(options);
			},
			getFriends(){
				var that = this;
				that.friendList = [];
				that.setFriendList = [];
				conn.getRoster({
				  success: function ( roster ) {
					  console.log(roster)
					  roster.forEach((item,index)=>{
						  var obj = {
							  name:item.name,
							  lastmsg:'今天中午吃什么',
							  time:'星期一',
							  chose:false,
							  noreadnum:0,
							  ishidden:true
						  }
						  that.friendList.push(obj)
						  that.setFriendList.push(obj)
						  console.log(that.friendList)
					  })
					  that.sendID = that.friendList[that.current].name;
				  },    
				});
			},
			getGroups(){
				var that = this;
				this.groupList = [];
				var options = {
				    success: function (resp) {
				        console.log("Response: ", resp)
						resp.data.forEach((item,index)=>{
							var obj = {
								groupid:item.groupid,
								name:item.groupname,
								lastmsg:'最后一条消息',
								time:'星期二'
							}
							that.groupList.push(obj)
						})
						console.log(that.groupList)
						console.log(that.current_group)
						that.groupid = that.groupList[that.current_group].groupid;
						console.log(that.groupid)
				    },
				    error: function (e) {}
				}
				setTimeout(()=>{
					if(this.isgroup && that.current_group != -1){
						that.yourname = that.groupList[that.current_group].name;
					}else{
						// that.yourname = that.friendList[that.current].name;
					}
				},500)
				conn.getGroup(options);
			},
			//创建群组时，选择好友
			chosefrtogrou(index){
				if(this.friendList[index].chose){
					this.friendList[index].chose = false;
				}else{
					this.friendList[index].chose = true;
					if(this.begrouparr.indexOf(this.friendList[index].name)==-1){
						this.begrouparr.push(this.friendList[index].name)
					}
				}
			},
			//点击通讯录好友
			choseAddressbook(index){
				this.resetmiddle();
				this.current_addressbook = index;
				this.friendDetailData = {
					sendID:this.friendList[this.current_addressbook].name,
					name:this.friendList[this.current_addressbook].name,
					type:'chat'
				}
				this.showfriendDetail = true;
			},
			//中间部分全部隐藏
			resetmiddle(){
				this.showchat = false;
				this.showfriendask = false;
				this.showfriendDetail = false;
				this.showrightside = false;
			},
			//左边部分全部隐藏
			resetleft(){
				this.current = -1;
				this.current_addressbook = -1;
				this.current_group = -1;
				this.yourname = '';
				this.showrightside = false;
			},
			resetchat_book_groupList(){
				this.current_lefticon = -1;
			},
			//“发消息”进入聊天界面事件
			chosepepsend(){
				var namearr = [];
				this.resetmiddle();
				this.resetleft();
				this.resetchat_book_groupList();
				this.current_lefticon = 0;
				this.sendID = this.friendDetailData.sendID;
				this.yourname = this.friendDetailData.name;
				this.type = this.friendDetailData.type;
				var obj = {
					sendID:this.sendID,
					name:this.friendDetailData.name,
					lastmsg:'',
					time:'2020-06-15',
					noreadnum:0,
					ishidden:true,
					type:this.friendDetailData.type
				}
				this.friendshowList.forEach((item,index)=>{
					namearr.push(item.name)
				})
				if(namearr.indexOf(this.yourname) == -1){
					this.friendshowList.unshift(obj)
					this.current = 0;
				}else{
					this.friendshowList.forEach((item,index)=>{
						if(item.name == this.yourname){
							this.current = index;
						}
					})
				}
				this.showchat = true;
			},
			//显示或隐藏消息图标的未读已读
			ifallmsgclear(){
				console.log('来了来了')
				var hiddenarr = [];
				this.friendshowList.forEach((item,index)=>{
					hiddenarr.push(item.ishidden)
				})
				console.log(hiddenarr)
				console.log(hiddenarr.indexOf(true))
				if(hiddenarr.indexOf(false) != -1){			
					console.log('有未读')
					//有未读
					this.allisdot = true
				}else{
					console.log('全都已读')
					//全都已读
					this.allisdot = false
				}
			},
			//显示群或好友详情
			showchatmess(){
				var that = this;
				this.showrightside = true;
				console.log(this.type)
				if(this.type == 'groupchat'){
					that.chatmemberList = [];
					that.setmemberList = [];
					var pageNum = 1,
					    pageSize = 1000;
					    var options = {
					        pageNum: pageNum,                                               // 页码
					        pageSize: pageSize,                                             // 预期每页获取的记录数
					        groupId: this.sendID,                                       
					        success: function (res) { 
								res.data.forEach((item,index)=>{
									if(item.member){
										var obj = {
											memberid:item.member,
											chose:false
										}
										that.chatmemberList.push(obj)
										that.setmemberList.push(obj)
									}
									if(item.owner){
										that.groupowner = {
											memberid:item.owner
										};
									}						
								})
								that.chatmemberList.unshift(that.groupowner)
								that.showchatmemberList = that.chatmemberList;
								that.showsetmemberList = that.setmemberList;
								console.log(that.name)
								console.log(that.groupowner)
								if(that.name == that.groupowner.memberid){
									console.log('管理员')
									that.isgroupowner = true;
								}
								console.log(that.chatmemberList)
							},
					        error: function(e){}
					    };
					conn.listGroupMember(options);
				}
			},
			//点击“删除”“添加”事件
			setgroup(status){
				//0 添加，1 删除
				this.groupsetstatus = status;
				if(status == 0){
					var member = [];
					this.setgroupmes = '添加群成员';
					this.chatmemberList.forEach((item,index)=>{
						this.setFriendList.forEach((items,indexs)=>{
							if(item.memberid == items.name){
								this.setFriendList.splice(indexs,1)
							}
						})
					})
					console.log(this.setFriendList)
					this.showsetgroupaddm = true;
				}else{
					this.setgroupmes = '删除群成员'
					this.showsetgroup = true;
				}
			},
			//搜索群成员(删除)
			searchsetmember(){
				if(this.membername){
					this.showsetmemberList = [];
					this.setmemberList.forEach((item,index)=>{
						if(item.memberid.indexOf(this.membername)>-1){
							this.showsetmemberList.push(item)
						}
					})
				}else{
					this.showsetmemberList = this.setmemberList
				}
			},
			//选择群成员删除
			chosesetmember(index){
				if(this.showsetmemberList[index].chose){
					this.showsetmemberList[index].chose = false;
				}else{
					this.showsetmemberList[index].chose = true;
				}
			},
			//移除群成员
			setGroupBtn(){
				var that = this;
				//移除群成员
				this.showsetmemberList.forEach((item,index)=>{
					if(item.chose){
						console.log(item.memberid)
						// return
						var option = {
						    groupId: that.groupid,
						    username: item.memberid,                         // 群组成员名称
						    success: function () {
						        that.$message({
						          message: '操作成功',
						          type: 'success'
						        });
								that.showsetgroup = false;
								that.getGroups()
						    }
						};
						conn.removeSingleGroupMember(option);
					}
				})
			},
			//添加群成员
			setGroupBtnAdd(){	
				console.log(1111)
				var that = this;
				var setmemberarradd = [];
				this.setFriendList.forEach((item,index)=>{
					if(item.chose){
						setmemberarradd.push(item.name)
					}
				})
				if(setmemberarradd.length<=0){
					this.$message.error('请选择好友')
					return
				}
				console.log(setmemberarradd)
				// 加好友入群
				var option = {
				    users: setmemberarradd,
				    groupId: that.groupid,
					success:function(res){
						that.$message({
						  message: '操作成功',
						  type: 'success'
						});
						that.showsetgroupaddm = false;
					},
					fail:function(resfa){
						console.log(resfa)
					}
				};
				conn.inviteToGroup(option);
			},
			//搜索群成员(添加)
			searchsetmemberadd(){
				this.setFriendList = [];
				if(this.membernameadd){
					this.friendList.forEach((item,index)=>{
						if(item.name.indexOf(this.membernameadd)>-1){
							this.setFriendList.push(item)
						}
					})
				}else{
					this.setFriendList = this.friendList
				}
				this.chatmemberList.forEach((item,index)=>{
					this.setFriendList.forEach((items,indexs)=>{
						if(item.memberid == items.name){
							this.setFriendList.splice(indexs,1)
						}
					})
				})
			},
			//选择好友拉入群
			chosesetmemberadd(index){
				if(this.setFriendList[index].chose){
					this.setFriendList[index].chose = false;
				}else{
					this.setFriendList[index].chose = true;
				}
			},
			//删除好友
			delfriend(){
				var that = this;
				console.log(this.sendID)
				var option = {
					to: this.sendID,
					success: function () {
						console.log('成功')
						that.$message({
						  message: '操作成功',
						  type: 'success'
						});
						that.friendshowList.forEach((item,index)=>{
							if(item.sendID == that.sendID){
								console.log(item)
								that.friendshowList.splice(index,1)
							}
						})
						that.showrightside = false;
						that.getFriends()
					},
				}
				conn.removeRoster(option);
			},
			//主动退群
			outGroup(){
				var that = this;
				console.log(this.groupid)
				var option = {
					to: this.name,
					groupId: this.groupid,
					success: function () {
						that.$message({
						  message: '操作成功',
						  type: 'success'
						});
						that.friendshowList.forEach((item,index)=>{
							if(item.sendID == that.groupid){
								that.friendshowList.splice(index,1)
							}
						})
						that.getGroups()
						that.showrightside = false;
						that.outGroupPop = false
					},
					error: function () {
						console.log('Leave room faild');
					}
				};
				conn.quitGroup(option);
			},
			//管理员解散群
			killoutGroup(){
				var option = {
					groupId: this.groupid,
					success: function () {
						that.$message({
						  message: '解散成功',
						  type: 'success'
						});
						that.getGroups()
						that.killGroupPop = false
					}
				};
				conn.dissolveGroup(option);
			},
			//申请加入群组
			joinGroup(){
				var that = this;
				if(!this.groupcode){
					this.$message.error('请填写群组号');
					return
				}
				var options = {
				        groupId: this.groupcode,                              // 群组ID
				        success: function(resp) {
				            console.log("Response: ", resp);
							that.$message({
							  message: '已申请',
							  type: 'success'
							});
							that.showjoingroup = false;
				        },
				        error: function(e) {
				            if(e.type == 17){
								that.$message.error('你已经在这个群组里了');
				            }
				        }
				    };
				conn.joinGroup(options);
			},
			//创建音视频会议
			creatMeeting(){
				var that = this;
				that.showvideocall = true;
				// confrType: 会议类型；password: 会议密码；rec:是否录制；recMerge：是否合并录制；supportWechatMiniProgram：会议是否支持微信小程序
				let params = {
					 confrType:'Communication', 
					 password:'123456', 
					 rec:false, 
					 recMerge:false, 
					 supportWechatMiniProgram:true,
					 maxTalkerCount:2,//会议最大主播人数
					 maxVideoCount: 6, //会议最大视频数
					 maxPubDesktopCount:1, //会议最大共享桌面数
					 maxAudienceCount:100 //会议最大观众数
				}
				emedia.mgr.createConference(params).then(function(confr){
					//创建会议
					console.log(confr);
					that.confrId = confr.confrId;
					that.password = confr.password;
					var ticket = confr.ticket;
					emedia.mgr.joinConferenceWithTicket(that.confrId,ticket).then(function(confr2){
						//加入会议
						console.log('加入会议')
						that.sendmsgfunc('视频会议中，点击进入','isvideo')
						var videohtml = document.createElement('video');
						var viclassname = videohtml.className;
						viclassname += 'videocall ';
						viclassname += that.name;
						videohtml.className = viclassname;
						var videoeachbox = document.createElement('div');
						videoeachbox.setAttribute("onclick", "videobig(this)");
						videoeachbox.className = 'videoeachbox';
						var videoeachname = document.createElement('p');
						videoeachname.innerHTML = that.name;
						videoeachbox.append(videohtml,videoeachname)
						document.getElementById('videobox').appendChild(videoeachbox)
						var constaints = {
							audio: true, 
							video: true		
						}
						emedia.mgr.publish(constaints,videohtml,'发布视频流').then(function(pushedStream){
							//发布音视频流,stream 对象
							console.log(pushedStream)
						}).catch(function(error3){
							console.log(error3)
						});
					}).catch(function(error2){
						console.log(error2)
					})
				}).catch(function(error){
					console.log(error)
				})				
			},
			//成员加入会议
			joinvideo(){
				var that = this;
				that.showvideocall = true;
				console.log('confrId:'+that.confrId)
				console.log('password:'+that.password)
				emedia.mgr.joinConference(that.confrId, that.password).then(function(confr){
					var videohtml = document.createElement('video');
					var viclassname = videohtml.className;
					viclassname += 'videocall ';
					viclassname += that.name;
					videohtml.className = viclassname;
					var videoeachbox = document.createElement('div');
					videoeachbox.setAttribute("onclick", "videobig(this)");
					videoeachbox.className = 'videoeachbox';
					var videoeachname = document.createElement('p');
					videoeachname.innerHTML = that.name;
					videoeachbox.append(videohtml,videoeachname)
					document.getElementById('videobox').appendChild(videoeachbox)
					var constaints = {
						audio: true, 
						video: true		
					}
					emedia.mgr.publish(constaints,videohtml,'发布视频流').then(function(pushedStream){
						//发布音视频流,stream 对象
						that.sendmsgfunc(that.name+'已加入视频会议','websocmes')
						console.log(pushedStream)
					}).catch(function(error3){
						console.log(error3)
					});
				}).catch(function(error){
				
				})
			},
			//成员退出会议
			outvideo(){
				emedia.mgr.exitConference();
				this.sendmsgfunc(this.name+'已退出视频会议','websocmes')
				$('.'+this.name).remove()
				this.showvideocall = false;
				if(this.videocallmember == 1){
					this.videochatting = false;
					this.sendmsgfunc('','closevideochatting')
				}
			},
			//共享屏幕
			// shareScream(){
			// 	var that = this;
			// 	let params_create = {
			// 		 confrType:'Communication', 
			// 		 password:'123456', 
			// 		 rec:false, 
			// 		 recMerge:false, 
			// 		 supportWechatMiniProgram:true,
			// 		 maxTalkerCount:2,//会议最大主播人数
			// 		 maxVideoCount:6, //会议最大视频数
			// 		 maxPubDesktopCount:1, //会议最大共享桌面数
			// 		 maxAudienceCount:100 //会议最大观众数
			// 	}
			// 	emedia.mgr.createConference(params_create).then(function(confr){
			// 		that.confrId = confr.confrId;
			// 		that.password = confr.password;
			// 		var ticket = confr.ticket;
			// 		emedia.mgr.joinConferenceWithTicket(that.confrId,ticket).then(function(confr2){
			// 			//加入会议
			// 			console.log('加入会议')
			// 			that.sendmsgfunc(that.name+'邀请你进入共享屏幕','issharescream')
			// 			var videohtml = document.createElement('video');
			// 			videohtml.style.width = '100px';
			// 			videohtml.style.opacity = '0';
			// 			document.getElementById('chatBigBox').appendChild(videohtml)
			// 			var constaints = {
			// 				audio: true, 
			// 				video: true		
			// 			}
			// 			emedia.mgr.publish(constaints,videohtml,'发布视频流').then(function(pushedStream){
			// 				//发布音视频流,stream 对象
			// 				console.log(pushedStream)
			// 				var videohtmls = document.createElement('video');
			// 				videohtmls.className = 'sharebox';
			// 				document.getElementById('chatBigBox').appendChild(videohtmls)
			// 				let params_share = {
			// 					videoConstaints:true, 
			// 					// withAudio:true, 
			// 					videoTag:videohtmls, 
			// 					// ext:'共享桌面', 
			// 					confrId:confr.confrId,
			// 					// stopSharedCallback:true
			// 				}
							
			// 				setTimeout(()=>{
			// 					emedia.mgr.shareDesktopWithAudio(params_share).then(function(pushedStream){
			// 					    //stream 对象
			// 						console.log('共享来啦',pushedStream)
			// 					}).catch(function(error){
								
			// 					});
			// 				},1000)
			// 			}).catch(function(error3){
			// 				console.log(error3)
			// 			});
			// 		}).catch(function(error2){
			// 			console.log(error2)
			// 		})
			// 	}).catch(function(error){
			// 		console.log(error)
			// 	})	
			// },
			shareScream(){
				var videohtml = document.createElement('video');
				videohtml.className = 'sharebox';
				document.getElementById('chatBigBox').appendChild(videohtml);
				let deskStream;
				var params = {
				    videoConstaints: true,
				    withAudio: true,
				    videoTag: videohtml,
				    // ext: '桌面流',
				    confrId: this.confrId,
				    stopSharedCallback: function () {
				        emedia.mgr.hungup(deskStream);
				    }
				
				}
				emedia.mgr.shareDesktopWithAudio(params).then(function (pushedStream) {
				    console.log('>>> 桌面共享成功', pushedStream);
				    deskStream = pushedStream;
				}).catch(function (error) {
				    console.log('>>> 桌面共享失败', error);
				});
			},
			//成员加入共享屏幕
			joinsharevideo(){
				var that = this;
				// that.showvideocall = true;
				console.log('confrId:'+that.confrId)
				console.log('password:'+that.password)
				emedia.mgr.joinConference(that.confrId, that.password).then(function(confr){
					var videohtml = document.createElement('video');
					var viclassname = videohtml.className;
					viclassname += 'sharevideo ';
					viclassname += that.name;
					videohtml.className = viclassname;
					document.getElementById('chatBigBox').appendChild(videohtml)
					var constaints = {
						audio: true, 
						video: true		
					}
					emedia.mgr.publish(constaints,videohtml,'加入共享桌面').then(function(pushedStream){
						//发布音视频流,stream 对象
						that.sendmsgfunc(that.name+'已加入共享桌面','websocmes')
						console.log(pushedStream)
					}).catch(function(error3){
						console.log(error3)
					});
				}).catch(function(error){
				
				})
			},
			pausevideo(){
				var that = this;
				var localVideoTag = $('.'+this.name)[0];
				console.log(localVideoTag)
				if(that.pausetxt == '暂停'){
					that.pausetxt = '开启'
					emedia.mgr.triggerPauseVideo(localVideoTag).then(function(res){
						console.log('暂停了',res)
						
					}).catch(function(){
					
					})
				}else{
					that.pausetxt = '暂停'
					emedia.mgr.triggerResumeVideo(localVideoTag).then(function(){
						console.log('开启了',res)
					}).catch(function(){
					
					})
				}
				
			}
		}
	})
	
	//有人加入会议，其他人调用joinXX等方法，如果加入成功，已经在会议中的人将会收到
	emedia.mgr.onMemberJoined = function (member) {
	    console.log('有人加入会议,其他人调用joinXX等方法，如果加入成功，已经在会议中的人将会收到')
		console.log(member)
	};
	//有人退出会议
	emedia.mgr.onMemberExited = function (member) {
	    console.log('有人退出会议')
		console.log(member)
		$('.'+member.name).remove()
	};
	//有媒体流添加；比如 自己调用了publish方法（stream.located() === true时），或其他人调用了publish方法。
	emedia.mgr.onStreamAdded = function (member, stream) {
		console.log('有媒体流添加',member)
		if(!stream.located()){
			var videohtml = document.createElement('video');
			videohtml.className = member.name
			var videoeachbox = document.createElement('div');
			videoeachbox.setAttribute("onclick", "videobig(this)");
			videoeachbox.className = 'videoeachbox';
			var videoeachname = document.createElement('p');
			videoeachname.innerHTML = member.name;
			videoeachbox.append(videohtml,videoeachname)
			document.getElementById('videobox').appendChild(videoeachbox)
			var constaints = {
				audio: true, 
				video: true		
			}
			emedia.mgr.streamBindVideo(stream, videohtml);
			emedia.mgr.subscribe(member, stream, true, true, videohtml)
		}	
	};
	//有媒体流移除
	emedia.mgr.onStreamRemoved = function (member, stream) {
		console.log('有媒体流移除')
		var videocall_length = $('.videocall').length;
		webvue.$message('有媒体流移除');
		if(webvue.videocallmember > 1){
			emedia.mgr.selectConfr(webvue.confrId,webvue. password).then(function(res){
			    console.log('会议信息',res)
				webvue.videocallmember = res.confr.memTotal;
			}).catch(function(error){
			
			})
		}
	};
	//角色改变
	emedia.mgr.onRoleChanged = function (role) {
		console.log('角色改变')
	};
	//会议退出；自己主动退 或 服务端主动关闭；
	emedia.mgr.onConferenceExit = function (reason, failed) {
	    var reason = (reason || 0);
	    switch (reason){
	        case 0:
	            reason = "正常挂断";
	            break;
	        case 1:
	            reason = "没响应";
	            break;
	        case 2:
	            reason = "服务器拒绝";
	            break;
	        case 3:
	            reason = "对方忙";
	            break;
	        case 4:
	            reason = "失败,可能是网络或服务器拒绝";
	            if(failed === -9527){
	                reason = "失败,网络原因";
	            }
	            if(failed === -500){
	                reason = "Ticket失效";
	            }
	            if(failed === -502){
	                reason = "Ticket过期";
	            }
	            if(failed === -504){
	                reason = "链接已失效";
	            }
	            if(failed === -508){
	                reason = "会议无效";
	            }
	            if(failed === -510){
	                reason = "服务端限制";
	            }
	            break;
	        case 5:
	            reason = "不支持";
	            break;
	        case 10:
	            reason = "其他设备登录";
	            break;
	        case 11:
	            reason = "会议关闭";
	            break;
	    }
		console.log(reason)
	};
	//管理员变更
	emedia.mgr.onAdminChanged = function(admin){
		console.log(admin)
	}
	
	function videobig(event){
		console.log(event)
		
		if($(event).hasClass('videobigger')){
			$(event).removeClass('videobigger')
			$('.videoeachbox').show();
		}else{
			$('.videoeachbox').hide();
			$(event).addClass('videobigger')
			$('.videobigger').show()
		}
	}
	function isMobile() {
		var userAgentInfo = navigator.userAgent
		var mobileAgents = [ "Android", "iPhone", "SymbianOS", "Windows Phone", "iPad","iPod"];
		var mobile_flag = false;
		//根据userAgent判断是否是手机
		for (var v = 0; v < mobileAgents.length; v++) {
			if (userAgentInfo.indexOf(mobileAgents[v]) > 0) {
				mobile_flag = true;
				break;
			}
		}
		 var screen_width = window.screen.width;
		 var screen_height = window.screen.height;   
		 //根据屏幕分辨率判断是否是手机
		 if(screen_width < 500 && screen_height < 800){
			 mobile_flag = true;
		 }
		 return mobile_flag;
	}
</script>
